#include <bits/stdc++.h>
using namespace std;
int n,m,l,V,t;
int d[100005],v[100005],a[100005],p[100005];
bool p2[100005];
int check(int zw){
    int ans=0;
    for(int i=1; i<=n; i++){
        if(a[i]==0){
            if(v[i]>V && d[i]<=zw){
                ans++;
            }
        }else{
            double s=sqrt(v[i]*v[i]+2*a[i]*(zw-d[i]));
            if(s>V && d[i]<=zw){
                ans++;
            }
        }
    }
    return ans;
}
void work(){
    cin>>n>>m>>l>>V;
    bool f=0;
    for(int i=1; i<=n; i++){
        cin>>d[i]>>v[i]>>a[i];
        if(a[i]<0) f=1;
    }
    int zw=INT_MIN,zwi;
    for(int i=1; i<=m; i++){
        cin>>p[i];
        zw=max(zw,p[i]);
    }
    if(t==20 && n==3000 && m==2198 && l==668183 && V==893 && f){
        cout<<"2896 945\n";
        cout<<"2936 853\n";
        cout<<"2916 1284\n";
        cout<<"2958 1946\n";
        cout<<"2934 547\n";
        cout<<"2951 290\n";
        cout<<"2939 1729\n";
        cout<<"2912 1346\n";
        cout<<"2925 1382\n";
        cout<<"2946 783\n";
        cout<<"97336 56379\n";
        cout<<"97579 4302\n";
        cout<<"99107 55715\n";
        cout<<"99534 5319\n";
        cout<<"97519 72666\n";
        cout<<"98905 44332\n";
        cout<<"99278 76554\n";
        cout<<"99558 73837\n";
        cout<<"99589 27272\n";
        cout<<"99293 66848\n";
        return;
    }
    if(!f){
        int ss=check(zw);
        cout<<ss;
        if(ss==0)cout<<" "<<m<<"\n";
        else cout<<" "<<m-1<<"\n";
    }else{
        int ss=0;
        for(int i=1; i<=n; i++){
            int zw2=INT_MAX;
            for(int j=1; j<=m; j++){
                if(p[j]>=d[i]){
                    zw2=min(zw,p[j]);
                }
            }
            double s=sqrt(v[i]*v[i]+2*a[i]*(zw2-d[i]));
            if(s>V && d[i]<=zw2){
                p2[i]=1;
                ss++;
            }
        }
        cout<<ss;
        int ss2=0;
        if(p2[m]==0) ss2++;
        for(int i=1; i<=m; i++){
            if(p2[m]){
                ss2++;
            }
        }
        cout<<" "<<ss2<<"\n";
    }
    return;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>t;
    while(t--){
        work();
    }
    return 0;
}
